/+
Library dbapi - Simple database api for the D programming language.

Copyright (C) 2007 Myron Alexander (myron.alexander...gmail.com)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+/

/+
This module is necessary as the circular reference created by having them in
their respective individual modules (transaction.d and statement.d) would
cause dmd to crash.
+/

module dbapi.internal.sqlite3.definitions;

enum StatementType {
     /**
      * The query statement. No data is modified and, when in transaction mode,
      * no transaction is started.
      */
     STATEMENT_QUERY = 1

     /**
      * Data will be modified by this statement. When in transaction mode, if a
      * transaction has not been started, a new transaction is started.
      * The conclusion of the statement may cause the transaction to be ended.
      */
   , STATEMENT_MODIFY

     /**
      * A transaction statement: BEGIN, COMMIT, ROLLBACK.
      */
   , STATEMENT_TRANSACTION

     /**
      * All other statement types such as DDL, transaction, pragmas etc.
      */
   , STATEMENT_OTHER
}

enum TransactionMode {
     /**
      * Auto-commit transaction mode will not create a transaction context
      * and each statement will be automatically committed at completion.
      *
      * The exception to this is that the executemany method will
      * create a transaction context for the bulk operation and commit
      * at the end. This is for performance purposes.
      *
      * The transaction type is ignored.
      */
     AUTO_COMMIT = 0

     /**
      * The user assumes control over transactions. This is similar to
      * AUTO_COMMIT but allows the developer to create their own transactions
      * using BEGIN statements. The interface will not handle any transaction
      * logic.
      *
      * The transaction type is ignored.
      */
   , USER

     /**
      * A transaction will be created with a statement that modifies the data
      * such as INSERT, UPDATE, DELETE. The transaction will be closed when
      * a commit or rollback statement is issued and will be recreated on
      * next modify statement.
      *
      * Transaction type determines what transaction mechanism is used.
      */
   , ON_MODIFY

     /**
      * The transaction context is created at the start of the connection.
      * A commit or rollback will end the context and create a new one.
      *
      * Transaction type determines what transaction mechanism is used.
      */
   , ALWAYS
}

enum TransactionType {
     /**
      * The default transaction type specified by the database.
      */
     DEFAULT = 0

     /**
      * Deferred means that no locks are acquired on the database until the
      * database is first accessed. Thus with a deferred transaction, the
      * BEGIN statement itself does nothing. Locks are not acquired until the
      * first read or write operation. The first read operation against a
      * database creates a SHARED lock and the first write operation creates a
      * RESERVED lock. Because the acquisition of locks is deferred until they
      * are needed, it is possible that another thread or process could create
      * a separate transaction and write to the database after the BEGIN on the
      * current thread has executed.
      */
   , DEFERRED

     /**
      * If the transaction is immediate, then RESERVED locks are acquired on all
      * databases as soon as the BEGIN command is executed, without waiting for
      * the database to be used. After a BEGIN IMMEDIATE, you are guaranteed
      * that no other thread or process will be able to write to the database
      * or do a BEGIN IMMEDIATE or BEGIN EXCLUSIVE. Other processes can continue
      * to read from the database, however.
      */
   , IMMEDIATE

     /**
      * An exclusive transaction causes EXCLUSIVE locks to be acquired on all
      * databases. After a BEGIN EXCLUSIVE, you are guaranteed that no other
      * thread or process will be able to read or write the database until
      * the transaction is complete.
      */
   , EXCLUSIVE
}

enum BatchResult {
     SUCCESS_NO_INFO = -2
   , EXECUTE_FAILED  = -3
}
